/*******************************************************************************************************

Table 6: Patronage

*******************************************************************************************************/

*Set directory path
cd "C:\Users\tsa23\Documents\petitions\replication files"

clear all

*read in our main dataset
use dta/did_rep.dta

*Elminate contrituencies which are not part of case L
drop if ID == 45 //University of Cambridge
drop if ID == 191 //University of Oxford
keep if sch_A==1 | sch_B == 1 | drummond!=.

drop if year==1830 | year==1831 | year==1832

gen treatgroup = 0
replace treatgroup =  1 if sch_A==1 

gen treatinter = treatperiod*treatgroup

collapse ln_petitions rottenindex_pre treatgroup, by(ID treatperiod treatinter)

label var treatinter "T * A" 
label var treatgroup "T" 
label var treatperiod "A" 

gen rotten_dummy = 0
replace rotten_dummy =1 if rottenindex_pre ==2
label var rotten_dummy "Patronage"

gen treatinter3 = treatperiod * treatgroup * rotten_dummy
label var treatinter3 "T * A * Patronage"

gen treatinter11 = treatperiod * rotten_dummy
label var treatinter11 "A * Patronage"

gen treatinter22 = treatgroup * rotten_dummy
label var treatinter22 "T * Patronage"

reg ln_petitions treatgroup treatperiod rotten_dummy treatinter treatinter22  treatinter11 treatinter3 , cl(ID)
outreg2 treatgroup treatperiod rotten_dummy treatinter treatinter22  treatinter11 treatinter3  using results\table6, nocons replace addt(Boroughs, 120, Treatment, L) tex(frag) asterisk(coef) auto(2) label se  symbol(**,*,+) ctitle(Log (petitions +1)) sortvar(treatgroup treatperiod rotten_dummy treatinter treatinter22  treatinter11 treatinter3) keep(treatgroup treatperiod rotten_dummy treatinter treatinter22  treatinter11 treatinter3)
test treatinter + treatinter3 = 0
